home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Befund4.cpp < prev    next >
C/C++ Source or Header  |  1998-12-22  |  2KB  |  81 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Befund4.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8.  
  9. const String DateiName = "Diagnose.txt";
  10. const String SammelName = "PsychoX.txt";
  11.  
  12. TForm1 *Form1;
  13. TStringList *Diagnose;
  14. TStringList *Psycho;
  15. int Nr;
  16.  
  17. //---------------------------------------------------------------------------
  18. __fastcall TForm1::TForm1(TComponent* Owner)
  19.     : TForm(Owner)
  20. {
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TForm1::FormCreate(TObject *Sender)
  24. {
  25.   randomize ();
  26.   Diagnose = new TStringList;
  27.   Psycho = new TStringList;
  28.   Diagnose->Add ("Keine Sprechstunde");
  29.   ScrollBar1->Min = 0;
  30.   ScrollBar1->Max = Diagnose->Count - 1;
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TForm1::Button1Click(TObject *Sender)
  34. {
  35.   Panel1->Caption = "";
  36.   Edit1->Text = "";
  37.   Edit1->SetFocus ();
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TForm1::Button2Click(TObject *Sender)
  41. {
  42.   Psycho->Add (Edit1->Text);
  43.   Nr = random (Diagnose->Count);
  44.   Panel1->Caption = Diagnose->Strings[Nr];
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::ScrollBar1Change(TObject *Sender)
  48. {
  49.   Panel1->Caption = Diagnose->Strings[ScrollBar1->Position];
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TForm1::Oeffnen1Click(TObject *Sender)
  53. {
  54.   try
  55.   {
  56.     if (OpenDialog1->Execute ())
  57.       Diagnose->LoadFromFile (OpenDialog1->FileName);
  58.     ScrollBar1->Max = Diagnose->Count - 1;
  59.   }
  60.   catch (...)
  61.   {
  62.     Application->MessageBox
  63.       ("Fehler beim ╓ffnen der Datei!", "Achtung!", 0+48);
  64.   }
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TForm1::Speichern1Click(TObject *Sender)
  68. {
  69.   try
  70.   {
  71.     if (SaveDialog1->Execute ())
  72.       Psycho->SaveToFile (SaveDialog1->FileName);
  73.   }
  74.   catch (...)
  75.   {
  76.     Application->MessageBox
  77.       ("Fehler beim Speichern der Datei!", "Achtung!", 0+48);
  78.   }
  79. }
  80. //---------------------------------------------------------------------------
  81.